#define _CRT_SECURE_NO_WARNINGS
#include"ConCurrentAlloc.h"
void MultiThreadAlloc1()
{
	std::vector<void*> v;
	for (size_t i = 0; i < 7; ++i)
	{
		void* ptr = ConCurrent::ConCurrentAlloc(6);
		v.push_back(ptr);
	}

	for (auto e : v)
	{
		ConCurrent::ConCurrentFree(e);
	}
}

void MultiThreadAlloc2()
{
	std::vector<void*> v;
	for (size_t i = 0; i < 7; ++i)
	{
		void* ptr = ConCurrent::ConCurrentAlloc(6);
		v.push_back(ptr);
	}

	for (auto e : v)
	{
		ConCurrent::ConCurrentFree(e);
	}
}
void alloc() {
	std::vector<void *> a;
	for (int i = 0; i <= 6; i++) {
		a.push_back(ConCurrent::ConCurrentAlloc(6));
	}
	for (auto e : a) {
		ConCurrent::ConCurrentFree(e);
	}
}
void alloc1() {
	std::vector<void*> a;
	for (int i = 0; i <= 6; i++) {
		a.push_back(ConCurrent::ConCurrentAlloc(16));
	}
	for (auto e : a) {
		ConCurrent::ConCurrentFree(e);
	}
}

void th() {
	std::thread t1(MultiThreadAlloc1);
	std::thread t2(MultiThreadAlloc2);
	t1.join();
	t2.join();
}
void text1() {
	void* p1 = ConCurrent::ConCurrentAlloc(6);
	void* p2 = ConCurrent::ConCurrentAlloc(5);
	void* p3 = ConCurrent::ConCurrentAlloc(4);
	void* p4 = ConCurrent::ConCurrentAlloc(8);
	void* p5 = ConCurrent::ConCurrentAlloc(7);
	void* p6 = ConCurrent::ConCurrentAlloc(6);
	void* p7 = ConCurrent::ConCurrentAlloc(6);

	std::cout << p1 << std::endl;
	std::cout << p2 << std::endl;
	std::cout << p3 << std::endl;
	std::cout << p4 << std::endl;
	std::cout << p5 << std::endl;
	ConCurrent::ConCurrentFree(p1);
	ConCurrent::ConCurrentFree(p2);
	ConCurrent::ConCurrentFree(p3);
	ConCurrent::ConCurrentFree(p4);
	ConCurrent::ConCurrentFree(p5);
	ConCurrent::ConCurrentFree(p6);
	ConCurrent::ConCurrentFree(p7);
}
void text3() {
	void* p8 = ConCurrent::ConCurrentAlloc((256 * 1024) + 1);
	void* p1 = ConCurrent::ConCurrentAlloc(129 * 8 * 1024);
	std::cout << p8 << std::endl;
	std::cout << p1 << std::endl;
 	ConCurrent::ConCurrentFree(p8);
	ConCurrent::ConCurrentFree(p1);
	int i = 0;
}
void text2() {
	for (int i = 0; i < 1024; ++i) {
		void* p1 = ConCurrent::ConCurrentAlloc(6);
		std::cout << p1 << std::endl;
	}
	void* p4 = ConCurrent::ConCurrentAlloc(8);
	std::cout << p4 << std::endl;

}

//int main() {
//	text1();
//	th();
//	std::cout << sizeof(PAGE_ID) << std::endl;
//}
